package com.example.library.service;

import com.example.library.mapper.UserInfoMapper;
import com.example.library.model.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: asus
 * Date: 2024-12-20
 * Time: 16:53
 */
@Slf4j
@Service
public class UserService {
    @Autowired
    private UserInfoMapper userInfoMapper;
    public UserInfo getUserInfoByname(String name) {
        return userInfoMapper.selectUserByName(name);
    }
    public Integer insertUserInfo(UserInfo userInfo) {
        Integer result = 0;

        try {
            if (userInfoMapper.selectUserByName(userInfo.getUserName()) != null) {
                return result;
            }
            result = userInfoMapper.insertUserInfo(userInfo);
        } catch (Exception e) {
            log.error("插入失败, e:{}", e.getMessage());
        }
        return result;
    }
}
